package com.canbot.u05.view;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.canbot.u05.R;

public class CenterDialogerror extends Dialog {

        private Context mContext;

        private String mTxt;

        private Handler mHandler = new Handler() {
                public void handleMessage(android.os.Message msg) {
                        CenterDialogerror.this.cancel();
                }

                ;
        };

        /**
         * btn采用默认的构造采用 *
         *
         * @param context
         * @param style
         * @param titleText
         * @param leftBtnText
         * @param rightBtnText
         * @param IClickListener
         */
        public CenterDialogerror(Context context, int style, String txt) {
                super(context, style);
                this.mContext = context;
                this.mTxt = txt;
        }

        @Override
        protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                initView(mTxt);
        }

        private void initView(String txt) {
                LayoutInflater layoutInflater = LayoutInflater.from(mContext);
                View viewDialog = layoutInflater.inflate(R.layout.dialog_center_connect_first,
                        null);
                TextView tv_tishi = (TextView) viewDialog.findViewById(R.id.tv_tishi);
                tv_tishi.setText(txt);
                setContentView(viewDialog);
                setCanceledOnTouchOutside(true);

        }

        @Override
        public void show() {
                super.show();
                mHandler.sendEmptyMessageDelayed(1, 2000);
        }

        @Override
        protected void onStop() {
                super.onStop();
                mHandler.removeMessages(1);
                Log.e("CenterDialogerror", "onStop");
        }

}

